﻿<%@ Page Title="" Language="C#" MasterPageFile="~/W_View/PageMaster.Master" AutoEventWireup="true" CodeBehind="DiviResultPage.aspx.cs" Inherits="STHPMS1.Web.W_View.Decision.Needs.DiviResultPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/datagrid.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/dropdown.js")%>
    <script>
        //确定最终方案
        function diviDelOther()
        {
            var row = $('#temp').datagrid('getSelected');
            if (!row) {
                $.messager.alert('消息提示', '确定最终方案时，请选择一项!', 'warning');
                return;
            }
            var rdid = $('#cmbRoadway').combobox('getValue'); //路线
            $.ajax({
                url: "/api/DiviResult/clearOther?rdid=" + rdid + "&m_w=" + row.Mainneed_Way,
                type: "post",
                complete: function () {
                    $.messager.progress('close');
                },
                success: function (msg) {
                    searchMainNeedWay();//查询划分方式
                    mysearch(row.Mainneed_Way);//查询该划分方式的划分详情
                },

                error: function (msg) {
                    $.messager.alert('错误提示', msg.responseText, "error");
                }
            });
        }

        function diviResultDel() {
            var row = $('#temp').datagrid('getSelected');
            if (!row) {
                $.messager.alert('消息提示', '删除数据时，请选择一项!', 'warning');
                return;
            }
            var rdid = $('#cmbRoadway').combobox('getValue'); //路线
            $.ajax({
                url: "/api/DiviResult/clear?rdid=" + rdid + "&m_w=" + row.Mainneed_Way,
                type: "post",
                complete: function () {
                    $.messager.progress('close');
                },
                success: function (msg) {
                    searchMainNeedWay();//查询划分方式
                    mysearch(row.Mainneed_Way);//查询该划分方式的划分详情
                },

                error: function (msg) {
                    $.messager.alert('错误提示', msg.responseText, "error");
                }
            });
        }

        //根据路线和划分方式查询路段详情
        function mysearch(m_w) {

            var rdid = $('#cmbRoadway').combobox('getValue'); //路线
            var url = '/api/DiviResult?';
            var urlParam = "";
            if (rdid != "") urlParam += "rdid=" + encodeURI(rdid);
            if (m_w != "") urlParam += "&m_w=" + $(m_w).attr("v");
            url = url + urlParam;
            $('#dg').datagrid({ url: url, pageNumber: 1 });
        }

        //查询划分方式
        function searchMainNeedWay()
        {
            var rdid = $('#cmbRoadway').combobox('getValue'); //路线
            var url = '/api/DiviResult/main?';
            var urlParam = "";
            if (rdid != "") urlParam += "rdid=" + encodeURI(rdid);
            url = url + urlParam;
            $('#temp').datagrid({ url: url, pageNumber: 1 });
        }

        //划分处理
        function divide() {
            $.messager.progress({
                title: '请等待',
                msg: '正在处理中...'
            });

            var gf = $('#cmbGF').combobox('getValue'); //规范
            var zb = $('#cmbZB').combobox('getValue'); //指标

            var rdid = $('#cmbRoadway').combobox('getValue'); //路线编号
            $.ajax({
                url: "/api/DiviResult/divide_test?rdid=" + rdid + "&gf=" + gf + "&zb=" + zb,
                type: "post",
                complete: function () {
                    $.messager.progress('close');
                },
                success: function (msg) {
                    closeFile();
                    searchMainNeedWay();//查询划分方式
                  // search(null, null);查询划分结果
                },

                error: function (msg) {
                    $.messager.alert('错误提示', msg.responseText, "error");
                }
            });
        }

        $(function () {

            var url = null; //默认不显示数据

            var number = '<%= Page.RouteData.Values["page"] %>';
            var size = '<%= Page.RouteData.Values["size"] %>';

            dataGridBind($('#dg'), url, '划分详情', $('#tb'), number, size);

            dataGridBind($('#temp'), url, '养护路段划分列表显示', $('#tb2'), number, size);

            $('.validatebox-text').bind('blur', function () {
                $(this).validatebox('enableValidation').validatebox('validate');
            });

        })
    </script>
    <script>
        //数据格式化
        function yh(val, row) {
            if (val == "12000")
                return "日常养护";
            else if (val == "12001")
                return "预防性养护";
            else if (val == "12002")
                return "中修";
            else if (val == "12003")
                return "大修";
            else if (val == "-1")
                return "未能划分养护类型";
        }
        function jcfs(val,row)
        {
            if(val=="0_13000")
                return  "规范方法-PSSI和PCI指标"
            else if (val == "0_13001")
                return "规范方法-RQI指标"
            else if (val == "0_13002")
                return "规范方法-SRI指标"
            else if (val == "1_14000")
                return "华美方法-PCI指标"
            else if (val == "1_14001")
                return "华美方法-PCI和PQI指标"
            else if (val == "1_14002")
                return "华美方法-PSSI和PCI指标"
            else if (val == "1_14003")
                return "华美方法-PSSI、PCI和PQI指标"
            else if (val == "1_14004")
                return "华美方法-PSSI、PCI、PQI和RL指标"
            return val;
        }
        function ldxq(val,row)
        {

            return "<a href='#' v='" + row.Mainneed_Way + "' onclick='mysearch(this);'>查看</a>"
        }

        function fdate(val, row) {
            var date = new Date(val);
            var time_str = date.getTime().toString();
            return time_str.substr(0, 10);
        }

        function xcdir(val, row) {
            if (val == "11")
                return "上行";
            else if (val == "12")
                return "下行";
            else if (val == "13")
                return "全幅";
        }

        //联动
        $(function () {
            var _mkid = $('#cmbGF').combobox({
                onSelect: function (record) {
                    _zhbid.combobox({
                        url: '/api/data/target?id=' + $("#cmbGF").combobox("getValue"),
                        valueField: 'id',
                        textField: 'text'
                    }).combobox('clear');
                }
            });
            var _zhbid = $('#cmbZB').combobox({
                valueField: 'id',
                textField: 'text'

            });

            //设置规范的默认值
            $('#cmbGF').combobox('setValue', '0');
        });

        //划分界面
        function show() {
            $('#dlgImport').dialog('open');
        }

        function closeFile() {
            $('#dlgImport').dialog('close');
        }

      
    </script>

    <script>
        //自定义指标界面
        function showCur() {
            $('#dlgCurImport').dialog('open');
        }
        function closeCur() {
            $('#dlgCurImport').dialog('close');
        }

        $(function () {
            $("#tbpci").show();
            $("#tbpqi").hide();
            $("#tbpssi").hide();

            var _mkid = $('#cmbCurZB').combobox({
                onSelect: function (record) {
                    if(record.id=="14000")
                    {
                        $("#tbpci").show();
                        $("#tbpqi").hide();
                        $("#tbpssi").hide();
                    }
                    else if (record.id == "14001") {
                        $("#tbpci").show();
                        $("#tbpqi").show();
                        $("#tbpssi").hide();
                    }
                    else if (record.id == "14002") {
                        $("#tbpci").show();
                        $("#tbpqi").hide();
                        $("#tbpssi").show();
                    }
                }
            });
        });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

     <table id="temp" class="easyui-datagrid content-place" data-options="toolbar:'#tb2'" ajaxcached="false">
        <thead>
            <tr>
                <th data-options="field:'Mainneed_Way',width:120" formatter="jcfs" >决策方式</th>
                <th data-options="field:'Divi_Time',width:120"  >划分时间</th>
                <th data-options="field:'null',width:120" formatter="ldxq">路段详情</th>
            </tr>
        </thead>
    </table>
     <!--测试数据命令-->
    <div id="tb2">
         路线名称:
        <select id="cmbRoadway" class="easyui-combobox" panelheight="80" style="width: 100px"
            data-options="url:'/api/S_Inspeaccse/RoadWay',method:'get',valueField:'Rdwayid',textField:'Name',
                            onLoadSuccess:function(data){ $('#cmbRoadway').combobox('setValue',data[0].Rdwayid);}">
        </select>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="searchMainNeedWay()">查询</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="diviResultDel()">删除</a>

        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-sum',plain:true" onclick="show()">划分</a>
          <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="showCur()">自定义指标值</a>
       <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="diviDelOther()">确定最终方案</a>

    </div>

    <br />

    <table id="dg" class="easyui-datagrid content-place" ajaxcached="false">
        <thead>
            <tr>
                <th data-options="field:'Mainsegid',width:320">养护路段编号</th>
                
                <th data-options="field:'Beginmp',width:120" formatter="formatPile">起点桩号</th>
                <th data-options="field:'Endmp',width:120" formatter="formatPile">终点桩号</th>
                <th data-options="field:'Segid_Main',width:120" formatter='yh'>养护类型</th>
                <th data-options="field:'Direction_Dictid',width:120" formatter="xcdir">行车方向</th>
                <th data-options="field:'Divi_Time',width:120" formatter="formatDate">划分时间</th>
                
                <th data-options="field:'Comments',width:180">备注</th>
            </tr>
        </thead>
    </table>

   


    <!--划分路段-->
    <div id="dlgImport" class="easyui-dialog" title="导入数据" style="width: 320px; height: 250px; padding: 10px" closed="true" data-options="
				iconCls: 'icon-save',
				buttons: '#dlg-buttonsImport'
			">

        <table>
            <tr>
                <td>划分方式:</td>
                <td>
                    <select id="cmbGF" class="easyui-combobox" panelheight="80" style="width: 100px">
                        <option value="0">规范方法</option>
                        <option value="1">华美方法</option>
                    </select></td>
            </tr>
            <tr>
                <td>采用指标:</td>
                <td>
                    <select id="cmbZB" class="easyui-combobox" panelheight="80" style="width: 180px" data-options="url:'/api/data/target?id=0',method:'get',valueField:'id',textField:'text',
                              onLoadSuccess:function(data){ $('#cmbZB').combobox('setValue',data[0].id);}">
                    </select>
                </td>
            </tr>

        </table>

    </div>
    <!--划分路段命令-->
    <div id="dlg-buttonsImport">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:divide();">确定</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:closeFile()">取消</a>
    </div>

    <!--自定义指标-->
    <!--划分路段-->
    <div id="dlgCurImport" class="easyui-dialog" title="自定义指标值" style="width: 320px; height: 350px; padding: 10px" closed="true" data-options="
				iconCls: 'icon-save',
				buttons: '#dlg-buttonsCurImport'
			">
        <table>
            <tr>
                <td>采用指标:</td>
                <td>
                    <select id="cmbCurZB" class="easyui-combobox" panelheight="80" style="width: 180px"
                        data-options="url:'/api/data/target?id=1',method:'get',valueField:'id',textField:'text',
                              onLoadSuccess:function(data){ $('#cmbCurZB').combobox('setValue',data[0].id);}">
                    </select>
                </td>
            </tr>
        </table>
        <table id="tbpci">
            <tr>
                <td>日常-预防边界值(PCI):</td>
                <td>
                    <input id="pci1" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:60' />
                </td>
            </tr>
            <tr>
                <td>预防-中修边界值(PCI):
                </td>
                <td>
                    <input id="pci2" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:55' />
                </td>
            </tr>
            <tr>
                <td>中修-大修边界值(PCI):
                </td>
                <td>
                    <input id="pci3" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:50' />
                </td>
            </tr>
        </table>
          <table id="tbpqi" >
            <tr>
                <td>日常-预防边界值(PQI):</td>
                <td>
                    <input id="pqi1" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:60' />
                </td>
            </tr>
            <tr>
                <td>预防-中修边界值(PQI):
                </td>
                <td>
                    <input id="pqi2" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:55' />
                </td>
            </tr>
            <tr>
                <td>中修-大修边界值(PQI):
                </td>
                <td>
                    <input id="pqi3" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:50' />
                </td>
            </tr>
        </table>
         <table id="tbpssi" >
            <tr>
                <td>日常-预防边界值(PSSI):</td>
                <td>
                    <input id="pssi1" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:60' />
                </td>
            </tr>
            <tr>
                <td>预防-中修边界值(PSSI):
                </td>
                <td>
                    <input id="pssi2" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:55' />
                </td>
            </tr>
            <tr>
                <td>中修-大修边界值(PSSI):
                </td>
                <td>
                    <input id="pssi3" class='easyui-validatebox easyui-numberbox' style="width: 100px" data-options='min:50' />
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td>公式</td>
                 <td>
                    <a id="curGS" href="#" ></a>
                </td>
            </tr>
        </table>
    </div>
    <!--划分路段命令-->
    <div id="dlg-buttonsCurImport">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="">确定</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="closeCur();">取消</a>
    </div>
</asp:Content>
